package level.editor.view;

import java.awt.BorderLayout;
import java.awt.Dimension;

import javax.swing.JFrame;
import javax.swing.JPanel;

import level.editor.view.desktop.Desktop;
import level.editor.view.menu.MainMenuBar;
import level.editor.view.toolbar.ToolBar;

public class Window extends JFrame
{
	public static final Dimension MINIMUM_SIZE = new Dimension(400, 400);
	public static final Dimension DEFAULT_SIZE = new Dimension(1400, 1000);

	public Window(String title)
	{
		super(title);
		init();
	}
	
	public Desktop getDesktop()
	{
		return desktop;
	}

	private void init()
	{
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // Change to
														// DO_NOTHING_ON_CLOSE
														// later
		LookAndFeel.initLookAndFeel();
		setMinimumSize(MINIMUM_SIZE);
		setSize(DEFAULT_SIZE);
		setVisible(true);
		
		addDesktop();
		addMenuBar();
		addToolBar();
		revalidate();
	}

	private void addDesktop()
	{
		JPanel panel = new JPanel(new BorderLayout());
		panel.setSize(this.getSize());
		setContentPane(panel);
		desktop = new Desktop(this);
		panel.add(desktop, BorderLayout.CENTER);
	}
	
	private void addMenuBar()
	{
		setJMenuBar(new MainMenuBar(this));
	}
	
	private void addToolBar()
	{
		getContentPane().add(new ToolBar(this), BorderLayout.NORTH);
	}
	
	private Desktop desktop;
}
